import React, { useEffect, useState } from 'react'

// 函数组件  || 无状态组件
export default function App() {
	//声明一个叫 "count" 的 state 变量
	const [count, setCount] = useState(1)

	useEffect(() => {
		console.log(`${count} count 值变了`)
	}, [])

	return (
		<div>
			<h1>{count}</h1>
			<button onClick={() => setCount(count + 1)}>+1</button>
		</div>
	)
}

// export default class App extends React.Component {
// 	state = {
// 		count: 1
// 	}
// 	render() {
// 		const { count } = this.state
// 		return (
// 			<div>
// 				<h1>{count}</h1>
// 				<button onClick={() => this.setState({ count: count + 1 })}>+1</button>
// 			</div>
// 		)
// 	}
// }